package com.sky.controller.admin;

import com.github.pagehelper.PageInfo;
import com.sky.constant.JwtClaimsConstant;
import com.sky.constant.PasswordConstant;
import com.sky.context.BaseContext;
import com.sky.dto.*;
import com.sky.entity.Employee;
import com.sky.entity.Rider;
import com.sky.properties.JwtProperties;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.EmployeeService;
import com.sky.service.RiderService;
import com.sky.utils.JwtUtil;
import com.sky.vo.EmployeeLoginVO;
import com.sky.vo.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*;

import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * 员工管理
 */
@RestController("adminRiderController")
@RequestMapping("/admin/rider")
@Slf4j
@Api(tags = "骑手相关接口")
public class RiderController {

    @Autowired
    private RiderService riderService;





    @PostMapping
    @ApiOperation("新增骑手")
    public Result add(@RequestBody RiderDTO riderDTO){
        riderService.add(riderDTO);
        return  Result.success();
    }
    @GetMapping("/page")
    @ApiOperation("骑手分页查询")
    public Result<PageResult> page(RiderPageQueryDTO riderPageQueryDTO){
        PageResult pageResult=riderService.pagelist(riderPageQueryDTO);
        return Result.success(pageResult);
    }
    @PostMapping("/status/{status}")
    @ApiOperation("启用禁用骑手账号")
    public  Result startorstop(@PathVariable Integer status,Long id){
        riderService.startorstop(status,id);
        return Result.success();
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询骑手")
    public Result<Rider> getByid(@PathVariable Integer id){
        Rider rider=riderService.getbyid(id);
        return Result.success(rider);
    }
    @PutMapping
    @ApiOperation("编辑骑手信息")
    public Result update(@RequestBody RiderDTO riderDTO){
        riderService.update(riderDTO);
        return Result.success();
    }


}

